package com.liuhangkai.firstpro.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component

@EnableScheduling
public class Task {
    @Autowired
    private EnforcerFactory enforcerFactory;

    @Scheduled(cron ="*/60 * * * * ?")
    public void executeTask (){
        if (enforcerFactory.enforcer !=null){
            enforcerFactory.enforcer.loadPolicy();
        }
        System.out.println("======定时执行");
    }
}
